package com.pig4cloud.pigx.contract.api.v1.websocket.handler;

import com.pig4cloud.pigx.common.customize.api.annotation.OpenApi;
import com.pig4cloud.pigx.common.websocket.handler.JsonMessageHandler;
import com.pig4cloud.pigx.contract.api.v1.websocket.manager.OpenApiWsManagerV1;
import com.pig4cloud.pigx.contract.api.v1.websocket.message.OpenApiSubscribeMessageV1;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;

/**
 */
@Slf4j
@Component
@AllArgsConstructor
@OpenApi(version = "1")
public class OpenApiSubscribeHandlerV1 implements JsonMessageHandler<OpenApiSubscribeMessageV1> {

	private OpenApiWsManagerV1 wsManager;

	@Override
	public void handle(WebSocketSession session, OpenApiSubscribeMessageV1 message) {
		wsManager.subscribe(session, message);
	}

	@Override
	public String type() {
		return OpenApiSubscribeMessageV1.TYPE;
	}

	@Override
	public Class<OpenApiSubscribeMessageV1> getMessageClass() {
		return OpenApiSubscribeMessageV1.class;
	}

}
